﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WSPay.Common;
using WSPay.Common.Data;

namespace WSPay.Domain
{
    public class PaymentOrder:IEntity
    {
        public PaymentOrder()
        {
            OrderId = "P".RandomNo();
        }

        /// <summary>
        /// 流水号
        /// </summary>
        public int ID { get; set; }

        public string OrderId { get; set; }
        /// <summary>
        /// 商品购买订单ID
        /// </summary>
        public string BuyOrderId { get; set; }

        /// <summary>
        /// 订单描述
        /// </summary>
        public string OrderInfo { get; set; }

        /// <summary>
        /// 支付通知订单ID/微信订单号
        /// </summary>
        public string NoticeSn { get; set; }

        /// <summary>
        /// 客户编号
        /// </summary>
        public Guid UserID { get; set; }

        /// <summary>
        /// 充值状态
        /// </summary>
        public PaymentState State { get; set; }

        /// <summary>
        /// 充值总额
        /// </summary>
        public decimal TotalPrice { get; set; }

        /// <summary>
        /// 支付总额
        /// </summary>
        public decimal PayAmount { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 支付宝账户/微信appid
        /// </summary>
        public string AliPayAccount { get; set; }

        /// <summary>
        /// 支付宝ID/微信商户号
        /// </summary>
        public string AliPayId { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 行级锁
        /// </summary>
        public byte[] RowVersion { set; get; }

        /// <summary>
        /// 任务ID
        /// </summary>
        public string JobId { get; set; }

        /// <summary>
        /// 返回RUL
        /// </summary>
        public string RuturnUrl { get; set; }

        public string NoticeUrl { get; set; }
        public string ClientID { get; set; }
    }

    public enum PaymentState
    {
        /// <summary>
        /// 未支付
        /// </summary>
        [EnumItemDescription("未支付")]
        Unpaid = 0,

        /// <summary>
        /// 等待处理
        /// </summary>
        [EnumItemDescription("等待处理")]
        Wait = 1,

        /// <summary>
        /// 完成
        /// </summary>
        [EnumItemDescription("完成")]
        Completed = 2,

        /// <summary>
        /// 失败
        /// </summary>
        [EnumItemDescription("失败")]
        Failure = 3,
        /// <summary>
        /// 退款
        /// </summary>
        [EnumItemDescription("退款")]
        Refund =4
    }
}
